#

| Chapter 23 Removing Files |

## 23.14 Handling a Filename Starting with a Dash (-)

Sometimes you can slip and create a file whose name starts with a dash (`-`), like -output or -f. That's a perfectly legal filename. The problem is that UNIX command options usually start with a dash (`-`). If you try to type that filename on a command line, the command might think you're trying to type a command option.

In almost every case, all you need to do is "hide" the dash from the command. Start the filename with `./` (dot slash). This doesn't change anything as far as the command is concerned; `./` just means "look in the current directory" (1.21). So here's how to remove the file -f:

>     % rm ./-f

(Most rm commands have a special option for dealing with filenames that start with a dash, but this trick should work on all UNIX commands.)

- JP

23.13 Deleting Files with the Null Name |  | 23.15 Using unlink to Remove a File with a Strange Name